/**
 * 用户相关接口
 */
import request from '@/config/request'
import {
  PlatformUserPasswordReqVO,
  PlatformUserProfilePasswordReqVO,
  PlatformUserProfileSaveReqVO
} from '@/types/user'

/**
 * 通过用户编号获取用户信息
 */
export const getUserProfile = (userId: number | string) => {
  return request.get({ url: '/system/user/profile', params: { userId } })
}

/**
 * 保存用户头像
 */
export const saveUserAvatar = (avatar: number) => {
  return request.put({ url: '/system/user/saveAvatar', params: { avatar } })
}

/**
 * 保存用户基本信息
 */
export const saveUserProfile = (data: PlatformUserProfileSaveReqVO) => {
  return request.put({ url: '/system/user/modify', data })
}

/**
 * 修改密码 - 登录的情况下
 */
export const modifyPassword = (data: PlatformUserProfilePasswordReqVO) => {
  return request.put({ url: '/system/user/modifyPassword', data })
}

/**
 * 修改密码 - 忘记密码
 */
export const modifyPasswordByUsername = (data: PlatformUserPasswordReqVO) => {
  return request.put({ url: '/system/user/modifyPasswordByUsername', data })
}

/**
 * 修改邮箱
 */
export const modifyEmail = (email: string) => {
  return request.put({ url: '/system/user/modifyEmail', params: { email } })
}
